package com.gj.my_aop.controller;

import cn.hutool.Hutool;
import cn.hutool.core.util.IdUtil;
import com.gj.my_aop.annotation.CustomerLogAnnotation;
import com.gj.my_aop.resp.ResultData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/customer")
@Slf4j
public class CustomerController {

    @GetMapping("/m1")
    public ResultData<String> m1(){
        String result = "";
        System.out.println("方法执行前日志。。。。");
        //耗时统计
        long startTime = System.currentTimeMillis();
        //主业务逻辑
        result = IdUtil.simpleUUID();
        System.out.println("生成订单号：" + result);
        long endTime = System.currentTimeMillis();
        System.out.println("业务耗时：" + (endTime-startTime) + "毫秒");
        System.out.println("方法执行后日志。。。。");

        return ResultData.success(result);
    }
    @GetMapping("/m2")
    @CustomerLogAnnotation(value="balabala",enable = true)
    public ResultData<String> m2(){
        String result = "";
        //主业务逻辑
        result = IdUtil.simpleUUID();
        System.out.println("生成订单号：" + result);

        return ResultData.success(result);
    }

    @GetMapping("/m3")
    @CustomerLogAnnotation(value="balabala",enable = false)
    public ResultData<String> m3(){
        String result = "";
        //主业务逻辑
        result = IdUtil.simpleUUID();
        System.out.println("生成订单号：" + result);

        return ResultData.success(result);
    }
}
